package nl.mvvenrooij.recommended.twitter;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import nl.mvvenrooij.recommended.twitter.data.Status;

import java.lang.reflect.Type;
import java.util.List;

public class Twitter {
    private final TwitterApi twitterApi;

    public Twitter(TwitterApi twitterApi) {
        this.twitterApi = twitterApi;
    }

    public List<Status> lastTweets() {
        Gson gson = new Gson();
        Type listType = new TypeToken<List<Status>>() {
        }.getType();
        return gson.fromJson(twitterApi.callTwitterApi(), listType);
    }
}